//
//  UpdateInfoViewController.m
//  MobileOffice
//
//  Created by jjkj on 16/10/21.
//  Copyright © 2016年 liaoningjujin. All rights reserved.
//

#import "UpdateInfoViewController.h"
#import "BasicModel.h"
#import "UpdateInfoModel.h"
#define appUpdate @"appUpdate"

@interface UpdateInfoViewController ()
{
    UpdateInfoModel *_infoModel;
}
@end

@implementation UpdateInfoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setNavigationTitle:@"更新信息"];
    [self setRightBackNavigation];
    [self setLeftBackNavigation];
    [self creatView];
    [self updateUserInfoRequest];
    // Do any additional setup after loading the view.
}

- (void)creatView{
    //当前版本
    NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
    UILabel *betaLabel=[MyControl creatLabelWithFrame:CGRectMake(8, 8, IPHONE_WIDTH-16, 40) text:[NSString stringWithFormat:@"当前版本：%@",[infoDictionary objectForKey:@"CFBundleShortVersionString"]]];
    betaLabel.font=FONT_14;
    CGFloat height=[LZXHelper textHeightFromTextString:betaLabel.text width:betaLabel.width fontSize:14];
    betaLabel.height=height+5;
    [self.view addSubview:betaLabel];
    
    //发布日期
    UILabel *dateLabel=[MyControl creatLabelWithFrame:CGRectMake(8, betaLabel.y+betaLabel.height+10, IPHONE_WIDTH-16, 40) text:@"发布日期:"];
    dateLabel.font=FONT_14;
    CGFloat height2=[LZXHelper textHeightFromTextString:dateLabel.text width:dateLabel.width fontSize:14];
    betaLabel.height=height2+5;
    [self.view addSubview:dateLabel];
    
    //修复问题
    UILabel *questionLabel=[MyControl creatLabelWithFrame:CGRectMake(8, dateLabel.y+dateLabel.height+10, IPHONE_WIDTH-16, 40) text:@"修复问题:"];
    questionLabel.font=FONT_14;
    CGFloat height3=[LZXHelper textHeightFromTextString:questionLabel.text width:questionLabel.width fontSize:14];
    questionLabel.height=height3+5;
    [self.view addSubview:questionLabel];
    
    //新增功能
    UILabel *addLabel=[MyControl creatLabelWithFrame:CGRectMake(8, questionLabel.y+questionLabel.height+10, IPHONE_WIDTH-16, 40) text:@"新增功能:"];
    addLabel.font=FONT_14;
    CGFloat height4=[LZXHelper textHeightFromTextString:addLabel.text width:addLabel.width fontSize:14];
    addLabel.height=height4+5;
    [self.view addSubview:addLabel];
}


#pragma mark - 更新版本信息
- (void)updateUserInfoRequest{
    
    NSDictionary *dict=@{
                         @"ver":@"61"
                         //                        @"reqStr":@"weaqtfaw"
                         };
    
    //   字典转json
    NSData* jsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:nil];
    NSString* str = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    //拼接soap字符串
    NSString* soap = [NSString stringWithFormat:@"<sessionId>%@</sessionId>\n<content>%@</content>",[LZXHelper getSessionID],str];
    [HttpRequest SOAPData:[LZXHelper getServerURL] SoapMthod:appUpdate soapBody:soap success:^(id responseObject) {
        [LZXHelper hideLoadViewWithView:self.view];
        
        //解析数据
         _infoModel=[[UpdateInfoModel alloc]initWithResponse:responseObject];
        if ([_infoModel.code isEqualToString:@"200"]) {
            //[LZXHelper postMessageWithText:_infoModel.msg View:self.view];
        }else if([_infoModel.code isEqualToString:@"220"]){
            [LZXHelper postMessageWithText:_infoModel.msg View:self.view];
        }
    } failure:^(NSError *error) {
        [LZXHelper hideLoadViewWithView:self.view];
    }];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
